namespace AdmissionQA.Domain.Entities;

/// <summary>
/// 专业信息实体
/// </summary>
public class MajorInfo : EntityBase
{
    /// <summary>
    /// 专业名称
    /// </summary>
    public string MajorName { get; private set; }

    /// <summary>
    /// 专业课程集合
    /// </summary>
    public List<string> Courses { get; private set; }

    /// <summary>
    /// 就业前景描述
    /// </summary>
    public string CareerProspects { get; private set; }

    /// <summary>
    /// 向量化Embedding字段
    /// </summary>
    public float[]? Embedding { get; set; }

    /// <summary>
    /// 构造函数
    /// </summary>
    private MajorInfo(string majorName, List<string> courses, string careerProspects)
    {
        MajorName = majorName;
        Courses = courses;
        CareerProspects = careerProspects;
    }

    /// <summary>
    /// 创建专业信息实例
    /// </summary>
    public static MajorInfo? CreateMajorInfo(
        string majorName,
        List<string> courses,
        string careerProspects
    )
    {
        // 可以加入一些条件判断

        return new MajorInfo(majorName, courses, careerProspects);
    }

    /// <summary>
    /// 更新专业信息
    /// </summary>
    public bool UpdateMajorInfo(
        string newMajorName,
        List<string> newCourses,
        string newCareerProspects,
        string? newDescription
    )
    {
        // 可以加入一些条件判断

        MajorName = newMajorName;
        Courses = newCourses;
        CareerProspects = newCareerProspects;
        Description = newDescription;

        return true;
    }

    /// <summary>
    /// 添加课程进入课程集合
    /// </summary>
    public bool AddCourses(string course)
    {
        if (Courses.Contains(course))
        {
            return false;
        }

        Courses.Add(course);

        return true;
    }

    /// <summary>
    /// 将课程移出课程集合
    /// </summary>
    public bool RemoveCourses(string course)
    {
        if (!Courses.Contains(course))
        {
            return false;
        }

        Courses.Remove(course);

        return true;
    }
}
